package com.stwyj.sbd.common;

/**
 * 错误信息枚举
 *
 * @author stwyj
 * @since 2018-11-30
 */
public enum AppErrors {
    // 无权限
    ERROR_NO_AUTH(1001, "没有权限"),
    // 用户名或者密码错误
    ERROR_USERNAME_PWD_IS_WRONG(1002, "用户名或者密码错误"),
    // 参数错误
    ERROR_PARAMS_IS_WRONG(1003, "请求参数错误"),
    // 参数错误
    ERROR_UPDATE_FAIL(1004, "更新用户信息失败");

    private Integer code;
    private String message;

    AppErrors(Integer code, String message) {
        this.code = code;
        this.message = message;
    }
    public Integer code() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String message() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public static String message(Integer code) {
        String message = null;
        for (AppErrors err : AppErrors.values()) {
            if (err.code().equals(code)) {
                message = err.message();
                break;
            }
        }
        return message;
    }
}
